import Vue from 'vue'
import App from './App'
import { request } from './utils/api.js'
import * as navTo  from './utils/navTo.js'

Vue.prototype.$request = request
Vue.prototype.$navTo = navTo
Vue.prototype.$getStorageSync= function(key){
	let value = uni.getStorageSync(key) ;
	if(value!=null && value!="" && value!=undefined) {
		return value ;
	} 
	return null 
};

Vue.prototype.$formatDate= function(date){
	const nDate = new Date(date) ;
	const year = nDate.getFullYear() ;
	const month = (nDate.getMonth()+1).toString().padStart(2,0) ;
	const day = nDate.getDate().toString().padStart(2,0) ;
	return year+'-'+month+'-'+day ;
};

Vue.filter('formatDate',(date)=>{
	const nDate = new Date(date) ;
	const year = nDate.getFullYear() ;
	const month = (nDate.getMonth()+1).toString().padStart(2,0) ;
	const day = nDate.getDate().toString().padStart(2,0) ;
	return year+'-'+month+'-'+day ;
})

Vue.filter('formatMonthDate',(date)=>{
	
	const nDate = new Date(date)
	const month = (nDate.getMonth()+1).toString().padStart(2,0)
	const day = nDate.getDate().toString().padStart(2,0)

	return month+'月'+day + '日'
})

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
